home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ObjectHelpers.h
-
- Contains: Functions to help you when you are working with Apple event objects.
-
- Written by: Andy Bachorski
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/21/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #ifndef _OBJECT_HELPERS_
- #define _OBJECT_HELPERS_
-
-
- // %%%%% need to change calls to object building function to pass a boolean
- // %%%%% parameter to control the disposal of descs passed in.
-
- //******************************************************************************
- // A private conditionals file to setup the build environment for this project.
-
- #include "PrivateConditionals.h"
-
-
- //********** Universal Headers ****************************************
-
- #include <AERegistry.h>
- #include <AEObjects.h>
- #include <AEPackObject.h>
- #include <Aliases.h>
- #include <Icons.h>
-
-
- //******************************************************************************
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT
- #pragma import on
- #endif
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
- #endif
-
-
- //******************************************************************************
-
- pascal OSErr OHAddAliasParameterFromFSS( const FSSpecPtr fssPtr,
- DescType keyword,
- AERecord *theRecordPtr );
- /*
- Add a parameter of type typeAlias to an AERecord (or AppleEvent) using the provided FSSpec.
-
- fssPtr input: Pointer to the FSSpec to use.
- keyword input: The key for the data to be added to the record.
- theRecordPtr input: Pointer to the record (or event) to add the data to.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 The value of target or alias parameter, or of
- both, is NIL, or the alias record is corrupt
- memFullErr -108 Not enough room in heap zone
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakeAliasDescFromFSSpec( const FSSpecPtr fssPtr,
- AEDesc *aliasDescPtr );
- /*
- Create and return an AEDesc of type typeAlias using the provided FSSpec.
-
- fssPtr input: Pointer to the FSSpec to use.
- aliasDescPtr input: Pointer to null AEDesc.
- output: an AEDesc of type typeAlias.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 The value of target or alias parameter, or of
- both, is NIL, or the alias record is corrupt
- memFullErr -108 Not enough room in heap zone
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakeAliasDesc( const AliasHandle aliasHandle,
- AEDesc *aliasDescPtr );
- /*
- Create and return an AEDesc of type typeAlias using the provided
- alias record.
-
- aliasHandle input: Handle to an alias record.
- aliasDescPtr input: Pointer to null AEDesc.
- output: an AEDesc of type typeAlias.
-
- RESULT CODES
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- */
-
-
- //******************************************************************************
-
- pascal OSErr OHMakeAliasObjectFromFSSpec( const FSSpecPtr fssPtr,
- AEDesc *containerObjPtr,
- AEDesc *aliasObjectPtr );
- /*
- Given an FSSpec, return an object descriptor containing an alias,
- contained by containerObj.
-
- fssPtr input: Pointer to the FSSpec to use.
- containerObjPtr input: Pointer to container object for object being created.
- aliasObjectPtr input: Pointer to null AEDesc.
- output: an alias object.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 The value of target or alias parameter, or of
- both, is NIL, or the alias record is corrupt
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- errAEWrongDataType -1703 Wrong Apple event data type
- errAENotAEDesc -1704 Not a valid descriptor record
- errAEBadListItem -1705 Operation involving a list item failed
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakeAliasObject( const AliasHandle aliasHandle,
- AEDesc *containerObjPtr,
- AEDesc *aliasObjectPtr );
- /*
- Given an AliasHandle, return an object descriptor containing an alias,
- contained by containerObj.
-
- aliasHandle input: Handle to an alias record.
- containerObjPtr input: Pointer to container object for object being created.
- aliasObjectPtr input: Pointer to null AEDesc.
- output: an alias object.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 Error in parameter list
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- errAEWrongDataType -1703 Wrong Apple event data type
- errAENotAEDesc -1704 Not a valid descriptor record
- errAEBadListItem -1705 Operation involving a list item failed
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakePropertyObject( const DescType propType,
- AEDesc *containerObjPtr,
- AEDesc *propertyObjPtr );
- /*
- Given a property type, create an new object descriptor for that property,
- contained by containerObj.
-
- propType input: Property type to use for object.
- containerObjPtr input: Pointer to container object for object being created.
- propertyObjPtr input: Pointer to null AEDesc.
- output: A property object.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 Error in parameter list
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- errAEWrongDataType -1703 Wrong Apple event data type
- errAENotAEDesc -1704 Not a valid descriptor record
- errAEBadListItem -1705 Operation involving a list item failed
- */
-
- //******************************************************************************
- pascal OSErr OHMakeProcessObject( const ProcessSerialNumber *psnPtr,
- AEDesc *containerObjPtr,
- AEDesc *psnObjPtr );
- /*
- Given a ProcessSerialNumber, create an new object descriptor for the PSN,
- contained by containerObj.
-
- psnPtr input: ProcessSerialNumber to use for object.
- containerObjPtr input: Pointer to container object for object being created.
- psnObjPtr input: Pointer to null AEDesc.
- output: A ProcessSerialNumber object.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 Error in parameter list
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- errAEWrongDataType -1703 Wrong Apple event data type
- errAENotAEDesc -1704 Not a valid descriptor record
- errAEBadListItem -1705 Operation involving a list item failed
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakeSelectionObject( const DescType selection,
- AEDesc *containerObjPtr,
- AEDesc *selectionObject );
- /*
- Given selection type, create an new object descriptor for a selection,
- contained by containerObj.
-
- selection input: Selection type to use for object.
- containerObjPtr input: Pointer to container object for object being created.
- selectionObject input: Pointer to null AEDesc.
- output: A property object.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 Error in parameter list
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- errAEWrongDataType -1703 Wrong Apple event data type
- errAENotAEDesc -1704 Not a valid descriptor record
- errAEBadListItem -1705 Operation involving a list item failed
- */
-
- //******************************************************************************
- pascal OSErr OHMakeIconSuite( const AEDescList *iconFamilyRecPtr,
- Handle *iconSuitePtr );
- /*
- Make an icon suite containing the icons in an icon family record, as returned
- by the Finder. Behaves simmilar to a call to GetIconSuite, i.e., a new icon
- suite handle will be returned in iconSuitePtr.
-
- iconFamilyRecPtr input: The icon family to process.
- iconSuitePtr input: Pointer to an icon suite handle variable
- output: An icon suite containing the icons from the
- icon family record.
-
- Result Codes
- ____________
- noErr 0 No error
- paramErr -50 The value of target or alias parameter, or of
- both, is NIL, or the alias record is corrupt
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakeIconFamilyRecord( const Handle iconSuite,
- const IconSelectorValue iconSelector,
- AEDescList *iconFamilyRecPtr );
- /*
- Make an icon family record containing the icons specified in the
- iconSelector parameter.
- The iconSuite parameter should contain an icon suite, as returned by a
- call to GetIconSuite.
-
- iconSuite input: The icon suite to build the record from.
- iconSelector input: Which icons to include in the record.
- iconFamilyRecPtr input: Pointer to null AEDesc.
- output: An AERecord that's been coerced to an
- icon family record.
-
- Result Codes
- ____________
- noErr 0 No error
- paramErr -50 The value of target or alias parameter, or of
- both, is NIL, or the alias record is corrupt
- memFullErr -108 Not enough room in heap zone
- errAECoercionFail -1700 Data could not be coerced to the requested
- Apple event data type
- */
-
- //******************************************************************************
-
- pascal OSErr OHMakePositionList( const Point position,
- AEDescList *posListPtr );
- /*
- Make position list (a list containing two longs representin the x and y values
- for the position of a Finder item).
-
- position input: A point specifying the position.
- posListPtr input: Pointer to an AEList (contents will be lost, but not disposed).
- output: A new AEList containing the x & y values for the position.
-
- Result Codes
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- */
-
- //******************************************************************************
-
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack()
- #endif
-
- #ifdef PRAGMA_IMPORT_OFF
- #pragma import off
- #elif PRAGMA_IMPORT
- #pragma import reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif// _OBJECT_HELPERS_
-